package com.mzy.olddate.demo.map;

import com.alibaba.fastjson.JSON;

import java.util.*;

/**
 * @author Ives
 * * @date 2021/11/30
 */
public class GetSonMap {
  /**
   * HashMap，删除子map中的数据（删除key对应的values中的map元素）
   * @param args
   */
  public static void main(String[] args) {
    HashMap<String, Object> hashMap = new HashMap<>();
    Map<String,String> map = new HashMap<>();
    map.put("useranme","maoyan");
    map.put("age","188");
    map.put("password","123456");
    hashMap.put("data", map);
    System.out.println(JSON.toJSONString(hashMap, true));
    // 过滤, 说明新的data还是原来的data
    HashMap data = (HashMap)hashMap.get("data");
    data.remove("password");
    System.out.println(JSON.toJSONString(hashMap, true));

    System.out.println("---------------------------");

    ArrayList<String> list = new ArrayList<>();
    list.add("1");
    list.add("2");
    list.add("3");
    list.add("4");
    HashMap<String, List<String>> objectObjectHashMap = new HashMap<>();
    objectObjectHashMap.put("test",list);
    System.out.println(JSON.toJSONString(objectObjectHashMap, true));

  }
}
